package mspdt.ontrade;

import java.io.File;
import java.util.ArrayList;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ProductAdapter extends ArrayAdapter<String> {
	private final Activity context;
	private final ArrayList<String> names;
	private final ArrayList<String> ings;
	private final ArrayList<Integer> l_images;
	private final ArrayList<Integer> r_images;
	private int selected = 0;
	DBAdapter db;
	
	public ProductAdapter(Activity context, ArrayList<String> names, ArrayList<String> ings, ArrayList<Integer> l_images, ArrayList<Integer> r_images) {
		super(context, R.layout.list_body, names);
		this.context = context;
		this.names = names;
		this.ings = ings;
		this.l_images = l_images;
		this.r_images = r_images;
		db = new DBAdapter(context);
	}
	
	public void setSelected(int id)
	{
		selected = id;
	}
	private int getSelected()
	{
		return selected;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = context.getLayoutInflater();
		View rowView = inflater.inflate(R.layout.list_body, null, true);
		
		TextView prod_name = (TextView)rowView.findViewById(R.id.prod_name);
		prod_name.setText(names.get(position));
		TextView prod_ing = (TextView)rowView.findViewById(R.id.prod_ing);
		prod_ing.setText(ings.get(position));
		
		ImageView l_image = (ImageView)rowView.findViewById(R.id.l_image);
		l_image.setImageResource(l_images.get(position));
//		ImageView r_image = (ImageView)rowView.findViewById(R.id.r_image);
//		r_image.setImageResource(r_images.get(position));
		return rowView;
	}
}